<template>
    <div>
      <nav-header></nav-header>
      <div class="m-main">
        <column></column>
        <div class="m-container">
          <router-view></router-view>
        </div>
      </div>
      <web-footer></web-footer>
    </div>

</template>

<script>
  import Column from '@/components/Column.vue'
  import Header from '@/components/Header.vue'
  import Footer from '@/components/Footer.vue'
  export default {
    components: {
      'column': Column,
      'nav-header': Header,
      'web-footer': Footer
    },
    mounted() {
      //组件开始挂载时获取用户信息
      this.getUserInfo();
    },
    methods: {
      getUserInfo() {
        if($.cookie('loginToken') && $.cookie('loginToken') !== 'null') {
          let store = this.$store;
          $.ajax({
            url : "http://123.206.80.54:7000/user/query",
            type : "POST",
            data : {
              loginToken : $.cookie('loginToken'),  //username or mobile number
            },
            dataType: "json",
            success : function(status, error, res) {
              //console.log(res.responseJSON.res)
              store.dispatch('changeUserInfo', res.responseJSON.res)
            }
          })
        }
      }
    }

  }
</script>

<style>
  .m-main {
    width: 1000px;
    margin: 0 auto;
    overflow: hidden;
    clear: both;
  }
</style>
